@extends('content.layouts.default')
@section('content')
    <div class="card">
        <div class="card-body">
            <ul class="nav nav-tabs nav-overflow header-tabs">
                <li class="nav-item">
                    <a href="{{route('content.category.index')}}" class="nav-link pb-3 ">
                        栏目列表
                    </a>
                </li>
                <li class="nav-item">
                    <a href="{{route('content.category.create')}}" class="nav-link pb-3 active">
                        发表栏目
                    </a>
                </li>
            </ul>
        </div>
        <form action="{{route('content.category.update',$category)}}" method="post">
            @csrf
            @method('PUT')
            <div class="card-body">
                <div class="card">
                    <div class="card-header">
                        基本设置
                    </div>
                    <div class="card-body">
                        <div class="form-group">
                            <label>栏目名称</label>
                            <input type="text" name="title" value="{{old('title',$category['title'])}}" required class="form-control" placeholder="" aria-describedby="helpId">
                        </div>
                        <div class="form-group">
                            <label>栏目模型</label>
                            <select name="parent_id" class="form-control">
                                @foreach($models as $model)
                                <option value="{{$model['id']}}"
                                {{$category['content_model_id']==$model['id']?'selected':''}}
                                >{{$model['title']}}</option>
                                    @endforeach
                            </select>
                        </div>
                        <div class="form-group">
                            <label>父级栏目</label>
                            <select name="parent_id" class="form-control">
                                <option value="0">顶级栏目</option>
                                @foreach($categorys as $cat)
                                    <option value="{{$cat['id']}}"
                                            {{--判断是否默认选中--}}
                                    {{--{{$cat['id']==$category['id']?'selected':''}}--}}
                                            {{$cat['is_parent']?'selected':''}}
                                            {{--当前栏目及其子栏目是不能作为其父级栏目的--}}
                     {{$cat['id']==$category['id'] || $cat['is_child'] ?'disabled':''}}
                                    >{{$cat['_title']}}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="form-group">
                            <label>栏目描述</label>
                            <textarea name="describe" class="form-control"  rows="3">{{$category['describe']}}</textarea>
                        </div>
                        <div class="form-group">
                            <label>封面栏目</label>
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="is_home" id="inlineRadio1" value="1" @if($category['is_home']==1) {{'checked'}} @endif >
                                <label class="form-check-label" for="inlineRadio1">是</label>
                            </div>
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="is_home" id="inlineRadio1" value="0"
                                       @if($category['is_home'] == 0)
                                           {{'checked'}}
                                           @endif
                                >
                                <label class="form-check-label" for="inlineRadio1">否</label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-header">
                        模板设置
                    </div>
                    <div class="card-body">
                        <div class="form-group">
                            <label>封面模板</label>
                            <input type="text" name="home_template" class="form-control" value="{{old('home_template',$category['home_template'])}}">
                        </div>
                        <div class="form-group">
                            <label>列表页模板</label>
                            <input type="text" name="list_template" class="form-control" value="{{old('list_template',$category['list_template'])}}">
                        </div>
                        <div class="form-group">
                            <label>文章内容页模板</label>
                            <input type="text" name="content_template" class="form-control" value="{{old('content_template',$category['content_template'])}}">
                        </div>
                    </div>
                </div>
            </div>
            <div class="card-footer text-muted">
                <button class="btn btn-primary btn-sm">保存提交</button>
            </div>
        </form>
    </div>
@endsection